package cn.zhagzheguo.xk.dao.impl;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.zhagzheguo.xk.dao.StudentDao;
import cn.zhagzheguo.xk.model.Student;

@Repository
public class StudentDaoImpl implements StudentDao {

	@Autowired
	SqlSessionFactory sqlSessionFactory;

	@Override
	public Student getStuByStuId(String stuid) {
		SqlSession session = null;
		try {
			session = sqlSessionFactory.openSession();
			Student stu = session.selectOne("cn.zhagzheguo.xk.mapper.StudentMapper.selectOne", stuid);
			return stu;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			if (session != null) {
				session.close();
			}
		}
	}

	public static void main(String[] args) {
		Student stu = new StudentDaoImpl().getStuByStuId("201400301174");
		System.out.println(stu);
	}

}
